package com.zh.blog.security.component;

import com.zh.blog.dto.UserDetailDto;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;

/**
 * 用户工具类
 * @author ZhengHao
 * Created At 2022/7/29.
 **/
@Component
public class UserUtils {

    public static UserDetailDto getLoginUser(){
        return (UserDetailDto) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    }
}